//
//  MainTableViewController.m
//  项目一
//
//  Created by 芮京 on 2018/9/27.
//  Copyright © 2018年 芮京. All rights reserved.
//

#import "MainTableViewController.h"

#import "NewsViewController.h"
#import "VideoViewController.h"
#import "PivdureViewController.h"
#import "JokeViewController.h" 

@interface MainTableViewController ()

@end

@implementation MainTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self create];
    
    
}
-(void)create{
    NSArray*arr=@[@"NewsViewController",@"VideoViewController",@"PivdureViewController",@"JokeViewController"];
    NSArray *unSelectedImg=@[@"新闻",@"视频",@"图片",@"段子"];
    NSArray *selected=@[@"新闻1",@"视频1",@"图片1",@"段子1"];
    
    //控制器数组
    NSMutableArray *viewcon=[NSMutableArray new];
    
    //更具控制器的名称创建相应的控制器 并
    for (int i=0; i<arr.count; i++) {
        //String-->cotroller
        
        UIViewController *vc=[[NSClassFromString(arr[i])alloc]init];
        
        //添加导航控制器
        UINavigationController *nav=[[UINavigationController alloc] initWithRootViewController:vc];
        
        //z设置Tabbritem 的 选中图片  未选中图片  标题
        nav.tabBarItem.image=[[UIImage imageNamed:unSelectedImg[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        nav.tabBarItem.selectedImage=[[UIImage imageNamed:selected[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        nav.title=unSelectedImg[i];
        
        nav.navigationBar.barTintColor=[UIColor blackColor];
        //添加到数组里
        [viewcon addObject:nav];
        
    }
    self.viewControllers=viewcon;
    
}

@end
